// LpingDlg.h : header file
//

#pragma once
#include "afxwin.h"
typedef unsigned long IPAddr;     // An IP address.

typedef struct tagIP_OPTION_INFORMATION 
{
	unsigned char      Ttl;              // Time To Live
	unsigned char      Tos;              // Type Of Service
	unsigned char      Flags;            // IP header flags
	unsigned char      OptionsSize;      // Size in bytes of options data
	unsigned char FAR *OptionsData;      // Pointer to options data
} IP_OPTION_INFORMATION;

typedef struct tagICMP_ECHO_REPLY 
{
	IPAddr                Address;       // Replying address
	unsigned long         Status;        // Reply IP_STATUS
	unsigned long         RoundTripTime; // RTT in milliseconds
	unsigned short        DataSize;      // Reply data size in bytes
	unsigned short        Reserved;      // Reserved for system use
	void FAR              *Data;         // Pointer to the reply data
	IP_OPTION_INFORMATION Options;       // Reply options
} ICMP_ECHO_REPLY;

typedef IP_OPTION_INFORMATION FAR* LPIP_OPTION_INFORMATION;
typedef ICMP_ECHO_REPLY FAR* LPICMP_ECHO_REPLY;
typedef HANDLE (WINAPI IcmpCreateFile)(VOID);
typedef IcmpCreateFile* lpIcmpCreateFile;
typedef BOOL (WINAPI IcmpCloseHandle)(HANDLE IcmpHandle);
typedef IcmpCloseHandle* lpIcmpCloseHandle;
typedef DWORD (WINAPI IcmpSendEcho)(HANDLE IcmpHandle, IPAddr DestinationAddress,
									LPVOID RequestData, WORD RequestSize,
									LPIP_OPTION_INFORMATION RequestOptions,
									LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout);
typedef IcmpSendEcho* lpIcmpSendEcho;

struct CPingReply
{
	in_addr	 Address;  //The IP address of the replier
	unsigned long RTT; //Round Trip time in Milliseconds
};

// CLpingDlg dialog
class CLpingDlg : public CDialog
{
	// Construction
public:
	char MSG11[230];
	CLpingDlg(CWnd* pParent = NULL);	// standard constructor

	// Dialog Data
	enum { IDD = IDD_LPING_DIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


	// Implementation
protected:
	HICON m_hIcon;
	CListBox listdlg1;
	UINT m_time;
	CString m_packsize;
	DWORD m_IP;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnBnClickedButton1();
	afx_msg void OnBnClickedButton2();
	DECLARE_MESSAGE_MAP()

public:
	void CPING(LPCTSTR pszHostName, CPingReply& pr, UCHAR nTTL, DWORD dwTimeout, UCHAR nPacketSize);
	void _CPING(int a);
	void AddListMsg(CString Msg);
};
